using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BB.Processes.Models.Mapping
{
    public class ClassificacaoMap : EntityTypeConfiguration<Classificacao>
    {
        public ClassificacaoMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("Classificacaos");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.UserId).HasColumnName("UserId");
            this.Property(t => t.CompeticaoId).HasColumnName("CompeticaoId");
            this.Property(t => t.JornadaId).HasColumnName("JornadaId");
            this.Property(t => t.W).HasColumnName("W");
            this.Property(t => t.D).HasColumnName("D");
            this.Property(t => t.L).HasColumnName("L");
            this.Property(t => t.GF).HasColumnName("GF");
            this.Property(t => t.GA).HasColumnName("GA");
            this.Property(t => t.Score).HasColumnName("Score");

            // Relationships
            this.HasRequired(t => t.Competicao)
                .WithMany(t => t.Classificacaos)
                .HasForeignKey(d => d.CompeticaoId);
            this.HasRequired(t => t.Jornada)
                .WithMany(t => t.Classificacaos)
                .HasForeignKey(d => d.JornadaId);
            this.HasRequired(t => t.UserProfile)
                .WithMany(t => t.Classificacaos)
                .HasForeignKey(d => d.UserId);

        }
    }
}
